home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2510.ZIP / TRSOURCE.EXE / EFFYIELD.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  954b  |  39 lines

  1. /*********
  2. *
  3. * EFFYIELD.C
  4. *
  5. * by Ralph Davis
  6. * modified by Tom Rettig
  7. *
  8. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  9. *
  10. *********/
  11.  
  12. /* EFFYIELD:  Effective Yield (Effective Rate of Interest)
  13.  
  14.               Computes effective annual interest for annual rate
  15.                  compounded specified number of times per year
  16.  
  17.               SYNTAX:  EFFYIELD(rate, conversions)
  18.                        where rate        = nominal interest rate
  19.                              conversions = number of times per year 
  20.                                            interest is compounded
  21.  
  22.               RETURNS:  true yield 
  23. */
  24.  
  25. #include "trlib.h"
  26.  
  27. TRTYPE effyield()
  28. {
  29.    if ( PCOUNT==2 && ISNUM(1) && ISNUM(2) )
  30.    {
  31.        double        rate = _parnd(1);
  32.        double conversions = _parnd(2);
  33.  
  34.        _retnd(pow(1.0 + (rate / conversions),conversions) - 1.0);
  35.    }
  36.    else
  37.       _retnd( (double)ERROR );
  38. }
  39.